```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring Boot配置加载优先级详解</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .priority-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            color: white;
            font-weight: bold;
            margin-right: 12px;
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 2px;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(86, 178, 254, 0.3);
            z-index: -1;
            transition: all 0.3s ease;
        }
        .highlight:hover::after {
            height: 50%;
            background-color: rgba(86, 178, 254, 0.5);
        }
        .mermaid {
            background-color: white;
            padding: 2rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6">Spring Boot 配置加载优先级</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8">深入解析配置加载机制与最佳实践</p>
            <div class="max-w-3xl mx-auto bg-white bg-opacity-10 p-6 rounded-lg backdrop-filter backdrop-blur-sm">
                <p class="text-lg md:text-xl leading-relaxed">
                    Spring Boot 配置文件的加载优先级决定了应用程序如何解析和合并不同来源的配置。这一优先级确保了应用的配置可以被正确地覆盖和管理。
                </p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="prose max-w-none prose-lg">
                <p class="text-gray-700 mb-8">
                    在Spring Boot应用中，配置可以来自多个来源，理解这些配置源的加载顺序对于正确管理应用配置至关重要。当多个配置源定义了相同的属性时，优先级高的配置源会覆盖优先级低的配置源。
                </p>
            </div>
        </section>

        <!-- Priority List -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-l-4 border-blue-500 pl-4">配置加载优先级详解</h2>
            
            <div class="space-y-6">
                <!-- Priority 1 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-red-500">1</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2">Command Line Properties（命令行参数）</h3>
                                <p class="text-gray-700 mb-4">
                                    命令行参数传递的属性具有最高优先级，可以覆盖所有其他配置源中的值。例如，<code class="bg-gray-100 px-2 py-1 rounded">--myapp.custom.property=value</code> 通过命令行传递的参数将优先于配置文件中的同一属性值。
                                </p>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="flex items-center text-sm text-gray-600">
                                        <i class="fas fa-terminal mr-2 text-blue-500"></i>
                                        <span>示例: <code>java -jar myapp.jar --server.port=8081</code></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Priority 2 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-orange-500">2</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2">Java System Properties（系统属性）</h3>
                                <p class="text-gray-700 mb-4">
                                    系统属性通过 JVM 启动参数设置，例如 <code class="bg-gray-100 px-2 py-1 rounded">-Dmyapp.custom.property=value</code>。系统属性的优先级高于配置文件中的属性，但低于命令行参数。
                                </p>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="flex items-center text-sm text-gray-600">
                                        <i class="fas fa-cog mr-2 text-blue-500"></i>
                                        <span>示例: <code>java -Dserver.port=8081 -jar myapp.jar</code></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Priority 3 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-amber-500">3</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2">OS Environment Variables（操作系统环境变量）</h3>
                                <p class="text-gray-700 mb-4">
                                    操作系统的环境变量可以通过 <code class="bg-gray-100 px-2 py-1 rounded">ENV</code> 或 <code class="bg-gray-100 px-2 py-1 rounded">export</code> 命令设置，例如 <code class="bg-gray-100 px-2 py-1 rounded">MYAPP_CUSTOM_PROPERTY=value</code>。环境变量的优先级高于配置文件中的属性，但低于系统属性和命令行参数。
                                </p>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="flex items-center text-sm text-gray-600">
                                        <i class="fas fa-server mr-2 text-blue-500"></i>
                                        <span>示例: <code>export SERVER_PORT=8081 && java -jar myapp.jar</code></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Priority 4 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-yellow-500">4</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2"><code>application.properties</code> / <code>application.yml</code></h3>
                                <p class="text-gray-700 mb-4">
                                    应用程序的主配置文件（<code class="bg-gray-100 px-2 py-1 rounded">application.properties</code> 或 <code class="bg-gray-100 px-2 py-1 rounded">application.yml</code>）在项目资源目录（如 <code class="bg-gray-100 px-2 py-1 rounded">src/main/resources</code>）下。文件中的属性在环境变量和系统属性之后被加载。
                                </p>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="flex items-center text-sm text-gray-600">
                                        <i class="fas fa-file-alt mr-2 text-blue-500"></i>
                                        <span>示例: <code>server.port=8080</code> (在application.properties中)</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Priority 5 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-lime-500">5</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2"><code>@PropertySource</code> annotations（<code>@PropertySource</code> 注解中的属性文件）</h3>
                                <p class="text-gray-700 mb-4">
                                    如果使用 <code class="bg-gray-100 px-2 py-1 rounded">@PropertySource</code> 注解指定了额外的属性文件，这些文件中的属性会被加载并覆盖较低优先级的配置。注意，这种方法不会覆盖 <code class="bg-gray-100 px-2 py-1 rounded">application.properties</code> 和 <code class="bg-gray-100 px-2 py-1 rounded">application.yml</code> 中的属性。
                                </p>
                                <div class="bg-gray-50 p-4 rounded-lg">
                                    <div class="flex items-center text-sm text-gray-600">
                                        <i class="fas fa-code mr-2 text-blue-500"></i>
                                        <span>示例: <code>@PropertySource("classpath:custom.properties")</code></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Priority 6 -->
                <div class="card-hover bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                    <div class="p-6">
                        <div class="flex items-start">
                            <span class="priority-badge bg-emerald-500">6</span>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-2">Default <code>application.properties</code> / <code>application.yml</code>（默认属性文件）</h3>
                                <p class="text-gray-700 mb-4">
                                    如果存在多个 <code class="bg-gray-100 px-2 py-1 rounded">application.properties</code> 或 <code class="bg-gray-100 px-2 py-1 rounded">application.yml</code> 文件，例如在不同的配置目录下，Spring Boot 将根据环境和应用程序的需求加载它们。这些文件的属性加载优先级最低，但仍然会影响最终的配置值。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Additional Notes -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-l-4 border-blue-500 pl-4">额外说明</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Profiles -->
                <div class="card-hover bg-white p-6 rounded-xl shadow-md border border-gray-100">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-layer-group text-blue-500 mr-3"></i>
                        Profiles（配置文件配置的环境）
                    </h3>
                    <p class="text-gray-700">
                        Spring Boot 支持不同的配置文件对应不同的运行环境，如 <code class="bg-gray-100 px-2 py-1 rounded">application-dev.properties</code>、<code class="bg-gray-100 px-2 py-1 rounded">application-prod.properties</code>。激活的 profile 会决定哪些配置文件的属性会被加载并应用。
                    </p>
                    <div class="mt-4 bg-blue-50 p-4 rounded-lg">
                        <div class="flex items-center text-sm text-blue-700">
                            <i class="fas fa-lightbulb mr-2"></i>
                            <span>可以使用<code>spring.profiles.active</code>属性或在启动时通过<code>--spring.profiles.active=dev</code>参数来激活特定的profile。</span>
                        </div>
                    </div>
                </div>

                <!-- Profile-specific Files -->
                <div class="card-hover bg-white p-6 rounded-xl shadow-md border border-gray-100">
                    <h3 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <i class="fas fa-file-code text-blue-500 mr-3"></i>
                        Profile-specific Files（特定 profile 的配置文件）
                    </h3>
                    <p class="text-gray-700">
                        如果配置文件中使用了 profile，例如 <code class="bg-gray-100 px-2 py-1 rounded">application-dev.properties</code>，这些文件的属性会根据激活的 profile 被加载。激活的 profile 的配置文件优先级高于默认的配置文件。
                    </p>
                    <div class="mt-4 bg-blue-50 p-4 rounded-lg">
                        <div class="flex items-center text-sm text-blue-700">
                            <i class="fas fa-info-circle mr-2"></i>
                            <span>Profile-specific配置会与主配置合并，相同属性会覆盖主配置中的值。</span>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Example Section -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-l-4 border-blue-500 pl-4">配置覆盖示例</h2>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden border border-gray-100">
                <div class="p-6">
                    <p class="text-gray-700 mb-6">
                        如果在不同的配置源中设置了相同的属性，Spring Boot 将按照上述优先级决定使用哪个值。例如：
                    </p>
                    
                    <div class="space-y-4">
                        <div class="flex items-center">
                            <span class="bg-red-100 text-red-800 px-3 py-1 rounded-full text-sm font-medium mr-3">1</span>
                            <span class="text-gray-700"><span class="font-semibold">Command Line</span>: <code>--myapp.custom.property=command-line-value</code></span>
                        </div>
                        <div class="flex items-center">
                            <span class="bg-orange-100 text-orange-800 px-3 py-1 rounded-full text-sm font-medium mr-3">2</span>
                            <span class="text-gray-700"><span class="font-semibold">System Property</span>: <code>-Dmyapp.custom.property=system-property-value</code></span>
                        </div>
                        <div class="flex items-center">
                            <span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm font-medium mr-3">3</span>
                            <span class="text-gray-700"><span class="font-semibold">Environment Variable</span>: <code>MYAPP_CUSTOM_PROPERTY=env-var-value</code></span>
                        </div>
                        <div class="flex items-center">
                            <span class="bg-yellow-100 text-yellow-800 px-3 py-1 rounded-full text-sm font-medium mr-3">4</span>
                            <span class="text-gray-700"><span class="font-semibold">application.properties</span>: <code>myapp.custom.property=application-properties-value</code></span>
                        </div>
                    </div>
                    
                    <div class="mt-8 p-6 bg-blue-50 rounded-lg border border-blue-100">
                        <div class="flex items-center">
                            <i class="fas fa-check-circle text-blue-500 text-2xl mr-4"></i>
                            <div>
                                <h4 class="font-bold text-blue-800 mb-1">最终使用的属性值</h4>
                                <p class="text-blue-700">
                                    实际使用的属性值将是 <code class="bg-blue-100 px-2 py-1 rounded">command-line-value</code>，因为它具有最高优先级。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-gray-800 border-l-4 border-blue-500 pl-4">配置优先级可视化</h2>
            
            <div class="mermaid">
                graph TD
                    A[命令行参数] -->|最高优先级| F[最终配置]
                    B[系统属性] --> F
                    C[环境变量] --> F
                    D[application.properties] --> F
                    E[@PropertySource] --> F
                    G[默认配置文件] -->|最低优先级| F
                    
                    style A fill:#ef4444,stroke:#dc2626,color:white
                    style B fill:#f97316,stroke:#ea580c,color:white
                    style C fill:#f59e0b,stroke:#d97706,color:white
                    style D fill:#84cc16,stroke:#65a30d,color:white
                    style E fill:#10b981,stroke:#059669,color:white
                    style G fill:#6ee7b7,stroke:#34d399,color:white
                    style F fill:#3b82f6,stroke:#2563eb,color:white
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col items-center text-center">
                <h3 class="text-xl font-bold mb-4">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="text-blue-300 hover:text-white transition-colors duration-200">
                    <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```